package com.sky.rabc.enums;

public enum PayStatus {
    /**
     * 未支付
     */
    PENDING("pending","未支付"),
    /**
     * 支付中
     */
    PROGRESS("progress","支付中"),
    /**
     * 支付成功
     */
    SUCCESSFUL("successful","支付成功"),
    /**
     * 支付失败
     */
    FAILED("failed","支付失败"),
    /**
     * 退款中
     */
    REFUND_PROCESSING("refund_processing","退款中"),
    /**
     * 退款失败
     */
    REFUND_FAILED("refund_failed","退款失败"),
    /**
     * 订单关闭
     */
    CLOSE("close","订单关闭");

    private String code;
    private String description;

    PayStatus(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static PayStatus getPayType(String code){
        for (PayStatus payType : PayStatus.values()) {
            if (payType.getCode().equals(code)){
                return payType;
            }
        }
        throw new IllegalArgumentException("Invalid code: " + code);
    }
}
